package org.chinarjy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.chinarjy.dto.PersonSkillDto;
import org.chinarjy.dto.PersonSkillInfo;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface PersonSkillMapper extends BaseMapper<PersonSkillDto> {
    @Select("select * from person")
    @Results(id="PersonSkill",//如果PersonSkillDto类没有加@TableName注解，字段会自动匹配，id是否设置没有影响，如果加了注解，id的值要与注解设置的value一致
            value = {
            @Result(property = "id",column = "id"),
            @Result(property = "skills",javaType = List.class,column = "id",
            many = @Many(select = "org.chinarjy.mapper.SkillMapper.getSkillById"))})
    List<PersonSkillDto> getAllPersonSkillDto();

    @Select("select person.*,dept_id,skill from person inner join skill on person.id = skill.id")
    List<PersonSkillInfo> getAllPersonSkillInfo();
}
